<?php

if (!defined('access')){
	die ('Direct access Denied!');
} else {
	
	define('libpagin', true);

	class Pagination {
		public function __construct($nb,$page){
			$data = execQuery("SELECT COUNT(*) AS nbnews FROM news")->fetch();
			
			$this->nb = $nb;
			$this->nbnews = $data['nbnews'];
			$this->page = $page;
		}
	
		public function getPage(){
			
			$f = 0;
			$t = $this->nb;
			$p = 1;
			
			while ($this->nbnews > 0){
				$this->nbnews = $this->nbnews - $this->nb;
				echo '<a href="index.php?page='. $this->page .'&from='. $f .'&to='. $t .'">Page '. $p++ .'</a>';
				$t = $t+$this->nb;
				$f = $f+$this->nb;
			}
			
		}
	}
}

?>